//
// rein-tests.js
// Written by Amy Groshek at Remote-Learner.net
// 2011.10.03
//
// Unit tests (sort of) for rein library
// Run in browser console
// To turn off while continuing to load into the page,
// set tests.doRun = false;
// When development is complete, simply do not load the script
// into your live environment
//
;(function($) {
// comment to test upstream changes
    $(document).ready( function(){

        var tests = {
          doRun: null,
          runTests: function() {
            console.log('Running tests of rein.js');
            // jquery defined
            if (jQuery) {
              console.log('Pass: jQuery is defined');
            } else {
              console.error('Fail: jQuery is not defined');
            }

            // jquery ui
            if (jQuery.ui) {
              console.log('Pass: jQuery.ui is defined');
            } else {
              console.error('Fail: jQuery.ui is not defined');
            }

            // raphael
            if (Raphael) {
              console.log('Pass: Raphael is defined');
            } else {
              console.error('Fail: Raphael is not defined');
            }

            // jmediaelement
            /* if (jQuery.fn.jmeEmbed) {
              console.log('Pass: jme is defined');
            } else {
              console.error('Fail: jme is not defined');
            }*/

            // click hotspot plugin existence
            if ( $.fn.clickhotspot ){
              console.log('Pass: click hotspot is defined');
            } else {
              console.error('Fail: click hotspot is not defined');
            }

            // if click hotspot exists, query length of children should be > 1
            if ( $('.clickHotspot').length >= 1 ){
              if ($('.clickHotspot').children().length >= 1) {
                console.log('Pass: click hotspot DOM element exists and has children.');
              } else {
                console.error('Fail: click hotspot DOM object detected but has no children.');
              }
            }

            // one item drag and drop plugin existence
            if ( $.fn.onedrag ){
              console.log('Pass: one item drag and drop is defined');
            } else {
              console.error('Fail: one item drag and drop is not defined');
            }

            // if one item drag and drop exists, query length of children should be > 1
            if ( $('.oneDrag').length >= 1 ){
              if ($('.oneDrag').children().length >= 1) {
                console.log('Pass: one item drag and drop DOM element exists and has children.');
              } else {
                console.error('Fail: one item drag and drop DOM object detected but has no children.');
              }
            }

            // sort multiple lists plugin existence
            if ( $.fn.draganddropsorting ){
              console.log('Pass: drag and drop list sorting is defined');
            } else {
              console.error('Fail: drag and drop list sorting is not defined');
            }


            // if sort multiple lists plugin exists, query length of children should be > 1
            if ( $('.sortMultipleLists').length >= 1 ){
              if ($('.sortMultipleLists').children().length >= 1) {
                console.log('Pass: Sort multiple lists DOM element exists and has children.');
              } else {
                console.error('Fail: Sort multiple lists DOM object detected but has no children.');
              }
            }

            // sort multiple lists plugin existence
            if ( $.fn.domultidrop ){
              console.log('Pass: domultidrop plugin is defined');
            } else {
              console.error('Fail: domultidrop plugin is not defined');
            }

            // if domultidrop plugin exists, query length of children should be > 1
            if ( $('.do-multi-drop').length >= 1 ){
              if ($('.do-multi-drop').children().length >= 1) {
                console.log('Pass: .do-multi-drop DOM element exists and has children.');
              } else {
                console.error('Fail: .do-multi-drop DOM object detected but has no children.');
              }
            }

            // stepwise plugin existence
            if ( $.fn.dostepwise ){
              console.log('Pass: dostepwise plugin is defined');
            } else {
              console.error('Fail: dostepwise plugin is not defined');
            }

            // if domultidrop plugin exists, query length of children should be > 1
            if ( $('.do-stepwise').length >= 1 ){
              if ($('.do-stepwise').children().length >= 1) {
                console.log('Pass: .do-stepwise DOM element exists and has children.');
              } else {
                console.error('Fail: .do-stepwise DOM object detected but has no children.');
              }
            }

            // sequential appearance plugin existence
            if ( $.fn.dosequential ){
              console.log('Pass: dosequential plugin is defined');
            } else {
              console.error('Fail: dosequential plugin is not defined');
            }

            // if sequential appearance plugin exists, query length of children should be > 1
            if ( $('.do-sequential').length >= 1 ){
              if ($('.do-sequential').children().length >= 1) {
                console.log('Pass: .do-sequential DOM element exists and has children.');
              } else {
                console.error('Fail: .do-sequential DOM object detected but has no children.');
              }
            }

          }// end runTests funct

        };// end tests object

        tests.doRun = true;

        if (tests.doRun) {
          tests.runTests();
        }// end if 

      });// end $(document).ready()

  })(jQuery);
